#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
int T, n, m, k, x, y, c, h[N], e[N], w[N], ne[N], idx, cnt[N], dist[N];
bool st[N];
queue<int> q;
void add(int a, int b, int c) {
	e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++;
}
bool spfa() {
	for(int i = 1; i <= n + m; i ++) {
		q.push(i);
		st[i] = true;
	}
	while(q.size()) {
		int u = q.front();
		q.pop();
		st[u] = false;	
		for(int i = h[u]; ~i; i = ne[i]) {
			int j = e[i];
			if(dist[j] < dist[u] + w[i]) {
				dist[j] = dist[u] + w[i];
				if(++ cnt[j] > n + m) return false;
				if(!st[j]) {
					q.push(j);
					st[j] = true;
				}
			}
		}
	}
	return true;
}
int main()
{
	scanf("%d", &T);
	while(T --) {
		memset(h, -1, sizeof h), idx = 0;
        memset(cnt, 0, sizeof cnt);
		scanf("%d%d%d", &n, &m, &k);
		for(int i = 0; i < k; i ++) {
			scanf("%d%d%d", &x, &y, &c);
			add(n + y, x, c);
			add(x, n + y, -c); 
		}
		printf(spfa() ? "Yes\n" : "No\n");
	}
	return 0;
}